<!--
 * @Description: 
 * @Author: 赵大壮
 * @Date: 2021-12-08 15:39:23
 * @LastEditTime: 2021-12-30 16:15:46
 * @LastEditors: 赵大壮
-->
<template>
  <div>
    <el-dialog title="修改密码" :visible.sync="isShowDialog" width="35%">
      <div class="flex flex-col pl-w20 pr-w40">
        <div class="flex flex-row items-center ">
          <div class="w-w1/4 flex flex-row justify-end mr-w10">
            <span class="text-red-600">*</span>新密码 ：
          </div>
          <el-input class="w-w3/4" v-model="pwd_new" placeholder="请输入新密码"></el-input>
        </div>
        <div class="flex flex-row items-center mt-w20">
          <div class="w-w1/4 flex flex-row justify-end mr-w10">
            <span class="text-red-600">*</span>确认新密码 ：
          </div>
          <el-input class="w-w3/4" v-model="pwd_new_again" placeholder="请再次输入新密码"></el-input>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button class=" bg-cmain" type="primary" @click="editPwd()">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script lang="ts">
import nyMessageToast from "@/utils/NYMessageToast";
import { Component, Vue, Prop, Watch } from "vue-property-decorator";

@Component
export default class UiTable extends Vue {
  @Prop() is_showDialog;

  isShowDialog = false;

  pwd_new = "";
  pwd_new_again = "";

  created() { }

  mounted() { }

  beforeDestroy() { }


  close() {
    this.$emit('nydialog_closed', '');
    this.initDialog();
  }
  initDialog() {
    this.isShowDialog = false;
  }

  @Watch("is_showDialog")
  watchShowDialog(value: any, oldValue: string) {
    this.isShowDialog = value;
  }

  dialog_control(show: boolean) {
    this.isShowDialog = show;
  }

  editPwd() {
    if (this.pwd_new.nyIsEmpty()) {
      nyMessageToast.warning("请输入新密码");
      return;
    }
    if (this.pwd_new.length < 6) {
      nyMessageToast.warning("密码不能小于6位");
      return;
    }
    if (this.pwd_new_again.nyIsEmpty()) {
      nyMessageToast.warning("请再次输入新密码");
      return;
    }
    if (this.pwd_new_again != this.pwd_new) {
      nyMessageToast.warning("请确认新密码是否正确");
      return;
    }
    this.$emit("editPwd", this.pwd_new);
    this.close();
  }
}
</script>
<style lang="less" scoped>

</style>
